﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for ThongKeWebSite
/// </summary>
public class ThongKeWebSite
{
    SqlCommand cmd;
    SqlDataReader dr;
	public ThongKeWebSite()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public void updateThongKe(ObjThongKeWebSite objThongKe)
    {
        string constr = System.Configuration.ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
        SqlConnection sqlConnection = new SqlConnection(constr);

        sqlConnection.Open();
        cmd = new SqlCommand("sp_ThongKeWebSite", sqlConnection);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter[] sqla = new SqlParameter[3];
        sqla[0] = new SqlParameter("@Tong_so_truy_cap", DbType.Int32);
        sqla[1] = new SqlParameter("@Tong_so_hom_nay", DbType.Int32);
        sqla[2] = new SqlParameter("@Ngay", DbType.String);

        sqla[0].Value = objThongKe.Tong_so_truy_cap;
        sqla[1].Value = objThongKe.Tong_so_hom_nay;
        sqla[2].Value = objThongKe.Ngay;
        cmd.Parameters.AddRange(sqla);
        cmd.ExecuteNonQuery();
        sqlConnection.Close();
    }
    public ObjThongKeWebSite getThongKe()
    {
        string constr = System.Configuration.ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
        SqlConnection sqlConnection = new SqlConnection(constr);

        sqlConnection.Open();
        cmd = new SqlCommand("sp_ThongKeWebSiteGet", sqlConnection);
        cmd.CommandType = CommandType.StoredProcedure;
        dr = cmd.ExecuteReader();
        ObjThongKeWebSite objThongKe = new ObjThongKeWebSite();
        if (dr.Read())
        {
            objThongKe.Tong_so_hom_nay = int.Parse(dr["tong_so_hom_nay"].ToString());
            objThongKe.Tong_so_hom_qua = int.Parse(dr["tong_so_hom_qua"].ToString());
            objThongKe.Tong_so_truy_cap = int.Parse(dr["tong_so_truy_cap"].ToString());
        }
        return objThongKe;
    }
}